﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="delproject.aspx.cs" Inherits="Mocola.Net.Web.delproject" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>确认删除</title>
    <link rel="stylesheet" href="css/content.css" type="text/css" />
    <link rel="stylesheet" href="css/ui.css" type="text/css" />
    <link rel="stylesheet" href="css/sys.css" type="text/css" />

    <script type="text/javascript" src="scripts/mootools-1.2-core.js"></script>
    <script type="text/javascript" src="scripts/mootools-1.2-more.js"></script>
    <script type="text/javascript" src="scripts/mocha.js"></script>
    <script type="text/javascript" src="scripts/dtree.js"></script>
    <script type="text/javascript" src="scripts/mocola-funs.js"></script>

</head>
<!--Being:[#20]-->
<body>
    <form id="form1">
    <div style="padding: 10 10 10 10">
        <div class="title1" style="padding-left: 10px; margin-bottom: 10px;">
            确认删除项：<b id="lblProject"></b>
        </div>
        <div id="divPwd" style="display: none; padding-left: 10px; margin-bottom: 20px;">
            确认密码：<input id="txtPwd" type="text" class="input1" style="width:90px;" />
        </div>
       <div align="center" style="margin-top:5px;">
            <input type="button" class="btnzc" value="确认删除" onclick="DeleteNode()" />
       </div>
    </div>
    </form>

    <script type="text/javascript">
          var isConfirm=<%= IsPasswordConfirm %>;
          window.addEvent('domready', function(){   
          $('lblProject').innerText=gup('name');         
          $("divPwd").style["display"]=isConfirm=="1"?"block":"none";
        });

        function DeleteNode()
        {
           var uid=gup("uid");
           var eid=gup ("eid");
           var name=gup("name");
           var pwd="";         
           if(isConfirm=="1")
           {
                pwd=escape($("txtPwd").value);
                if(pwd=="")
                {
                    alert("请输入密码！");
                    return false;
                }            
           }          
            var reqValues = new Request.HTML({url:'ajax/DeleteNode.aspx?uid='+uid+'&eid='+eid+'&pwd='+pwd,
            onSuccess: function(html) {
                var msg = html.item(0).nodeValue;		         
                /*
                密码不匹配 -1 删除失败  -2  删除成功   0  文件记录数 n(n>0)
                */
                var v=parseInt(msg);
                switch(v)
                {
                    case -2:
                    alert("删除失败");
                    break;
                    case -1:
                    alert("您没有删除权限，请提供正确的密码！");
                    break;                        
                    case 0:
                      window.parent.MochaUI.notification("删除成功!"); 
                      window.parent.MochaUI.closeWindow(window.parent.$('delproject'));
                      window.parent.MochaUI.updateContent({
		                element:  window.parent.$('left-panel'),
		                loadMethod: 'iframe',
		                url: 'left-projects.aspx'
	                  });
                    break;
                    default:
                        if(v>0)
                        {
                            alert("不能删除"+name+",该目录下包括["+v+"]条图纸或文件信息!");
                            window.parent.MochaUI.closeWindow(window.parent.$('delproject'));
                        }
                        else
                        {
                             window.parent.MochaUI.notification("未知消息!"); 
                             window.parent.MochaUI.closeWindow(window.parent.$('delproject'));
                        }
                    break;
                }		           
            },
            onFailure: function() {
	            window.parent.MochaUI.notification('表单提交失败！');;
            }
        }).post($('form1'));		       
        }
    </script>

</body>
<!--End:[#20]-->
</html>
